package android.slc.sys.ui;

import android.os.Bundle;
import android.slc.appbase.ui.activity.base.AppMvvmBaseActivity;
import android.slc.extras.system.domain.StartupPermissionsVd;
import android.slc.sys.R;
import android.slc.sys.databinding.SysActivityWecomeBinding;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.BarUtils;

/**
 * @author slc
 * @date 2020-07-10 11:09
 */
public class WelcomeActivity extends AppMvvmBaseActivity<SysActivityWecomeBinding, WelcomeVm> {

    private StartupPermissionsVd startupPermissionsVd;

    @Override
    public Object setContentView() {
        return R.layout.sys_activity_wecome;
    }

    @Override
    public void onBindViewBefore() {
        super.onBindViewBefore();
        if (!isTaskRoot()) {
            finish();
        }
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState) {
        super.onBindView(savedInstanceState);
        BarUtils.setStatusBarVisibility(this, false);
        BarUtils.setNavBarVisibility(this, false);
        startupPermissionsVd = new StartupPermissionsVd();
        startupPermissionsVd.init(this, getDataBinding().developersContentView, viewModel.startupPermissionsVmBox);
    }

    @Override
    public void onBindViewLater() {
        super.onBindViewLater();
        getDataBinding().setVm(viewModel);
        viewModel.init();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        if (viewModel.startupUiTaskVmBox.isTaskEnd()) {
            startupPermissionsVd.againCheckPermission();
        }
    }

}
